<template>
  <div>
    <el-date-picker
      v-model="val"
      :type="column.model || 'date'"
      placeholder="选择日期时间"
      value-format="yyyy-MM-dd"
      :picker-options="pickerOptions()"
      @change="handleChange"
    ></el-date-picker>
  </div>
</template>

<script>
import { props, mixin } from '@/components/control/basis'

export default {
  name: 'DateCom',
  props: {
    ...props,
    disabledTodayAndBeforeToday: Boolean,
    disabledToday: Boolean,
  },
  mixins: [mixin],
  watch: {},
  computed: {},
  data() {
    return {
      val: '',
    }
  },
  methods: {
    pickerOptions() {
      return {
        disabledDate: (time) => {
          // 禁用当前时间之前的日期
          if (this.disabledTodayAndBeforeToday)
            return time.getTime() < new Date() - 8.64e7
          // 禁用今天及今天之前的日期
          if (this.disabledToday) return time.getTime() < new Date()
          return false
        },
      }
    },
  },
}
</script>

<style scoped lang="scss"></style>
